﻿using System.Globalization;
using System.Windows.Data;

namespace MetaView.Ticket.Tools.Converter
{
    internal class LanguageNumToBooleanConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            int languageNum = (int)value;
            int selectedLanguageNum = int.Parse(parameter.ToString()!);

            return languageNum == selectedLanguageNum;
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            bool isSelected = (bool)value;
            int selectedLanguageNum = int.Parse(parameter.ToString()!);

            return isSelected ? selectedLanguageNum : Binding.DoNothing;
        }
    }

}
